home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / spiele / gemamigo / src / gemui.cc < prev    next >
C/C++ Source or Header  |  1998-10-29  |  1KB  |  81 lines

  1. #include "amigo.h"
  2. #include "gemui.h"
  3. #include "gamewin.h"
  4. #include "gemamigo.h"
  5.  
  6. #include <gemal.h>
  7. #include <gemap.h>
  8. #include <gema.h>
  9. #include <gemr.h>
  10.  
  11. #define RSCFILE "GEMAMIGO.RSC"
  12.  
  13. GEM_UI::GEM_UI() :
  14.     app(new GEMapplication),rsc(0),act(0),win(0)
  15. {
  16.     rsc=new GEMrsc(RSCFILE,8,16);
  17.  
  18.     if (!*rsc) {
  19.         GEMalert norsc("File not found:|" RSCFILE, "Abort");
  20.         norsc.Alert();
  21.         delete rsc;
  22.         rsc=0;
  23.     } else {
  24.         act=new GEMactivity;
  25.         win=new GameWindow(*act,*rsc);
  26.     }
  27. }
  28.  
  29. GEM_UI::~GEM_UI()
  30. {
  31.     delete win;
  32.     delete act;
  33.     delete rsc;
  34.     delete app;
  35. }
  36.  
  37.  
  38. void GEM_UI::Go()
  39. {
  40.     //win->Open(); -- it opens itself, so as to get under viewwin
  41.  
  42.     act->BeginDo();
  43.     while (win->IsOpen()) {
  44.         act->OneDo();
  45.     }
  46.     act->EndDo();
  47. }
  48.  
  49. void GEM_UI::RemoveStone(int x, int y)
  50. {
  51.     win->RemoveStone(x,y);
  52. }
  53.  
  54. void GEM_UI::PlaceStone(bVal c, int x, int y)
  55. {
  56.     win->PlaceStone(c,x,y);
  57. }
  58.  
  59. void GEM_UI::PrisonerReport(int b, int w)
  60. {
  61.     win->PrisonerReport(b,w);
  62. }
  63.  
  64. void GEM_UI::ShowResult(int wt, int bp, int bt, int wp)
  65. {
  66.     GEMform results(*rsc,RESULT);
  67.     
  68.     int wtot=wt+bp;
  69.     int btot=bt+wp;
  70.  
  71.     sprintf(results[WHITE_SCORES].Text(),"%3d%3d%3d",wt,bp,wtot);
  72.     sprintf(results[BLACK_SCORES].Text(),"%3d%3d%3d",bt,wp,btot);
  73.  
  74.     results[WHITE_IS_WINNER].HideTree(wtot<=btot);
  75.     results[BLACK_IS_WINNER].HideTree(wtot>=btot);
  76.     results[NO_WINNER].HideTree(wtot!=btot);
  77.  
  78.     results.Do();
  79. }
  80.  
  81.